public class SolutionInterview1_5 {
    public boolean oneEditAway(String first, String second) {
        if (first.length()==second.length()){
            int num=0;
            for (int i=0;i<first.length();i++){
                if (first.charAt(i)!=second.charAt(i)){
                    num++;
                }
            }
            return num<=1;
        }
        if (first.length()>second.length()){
            String temp=first;
            first=second;
            second=temp;
        }
        if (second.length()-first.length()>1){
            return false;
        }
        int t=0;
        int i=0,j=0;
        while (i<first.length()){
            if (first.charAt(i)!=second.charAt(j)){
                if (t!=0){
                    return false;
                }
                t=1;
                j++;
                if (first.charAt(i)!=second.charAt(j)){
                    return false;
                }
            }
            i++;
            j++;
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new SolutionInterview1_5().oneEditAway("pale","ple"));
    }
}
